package com.lsa.letcode.the73.setMatrixZeroes;

import static org.junit.Assert.*;

import org.junit.Test;

public class SetMatrixZeroesTest {
	@Test
	public void test() throws Exception {
		
		test(new int[][] { 
				{ 1, 2, 3 }, 
				{ 5, 7, 9 }, 
				{ 11, 13, 15 },
				{ 17, 19, 21 }
			 }, 
			 new int[][] { 
					{ 1, 2, 3 }, 
					{ 5, 7, 9 }, 
					{ 11, 13, 15 },
					{ 17, 19, 21 }
			 });
		
		test(new int[][] { 
				{ 0, 2, 3 }, 
				{ 5, 7, 9 }, 
				{ 11, 0, 15 },
				{ 17, 19, 0 }
			 }, 
			 new int[4][3]);
		
		test(new int[][] { 
				{ 1, 2, 3 }, 
				{ 5, 7, 9 }, 
				{ 11, 13, 15 },
				{ 17, 0, 21 }
			 }, 
			 new int[][] { 
					{ 1, 0, 3 }, 
					{ 5, 0, 9 }, 
					{ 11, 0, 15 },
					{ 0, 0, 0 }
			 });
		
		test(new int[][] { 
				{ 0, 2, 3 }, 
				{ 5, 0, 9 }, 
				{ 11, 13, 15 },
				{ 17, 19, 21 }
			 }, 
			 new int[][] { 
					{ 0, 0, 0 }, 
					{ 0, 0, 0 }, 
					{ 0, 0, 15 },
					{ 0, 0, 21 }
			 });
		
		test(new int[][] { 
				{ 1, 2, 3 }, 
				{ 0, 7, 9 }, 
				{ 11, 13, 15 },
				{ 17, 19, 21 }
			 }, 
			 new int[][] { 
					{ 0, 2, 3 }, 
					{ 0, 0, 0 }, 
					{ 0, 13, 15 },
					{ 0, 19, 21 }
			 });
		
		test(new int[][] { 
				{ 0, 2, 3 }, 
				{ 5, 7, 9 }, 
				{ 11, 13, 15 },
				{ 17, 19, 21 }
			 }, 
			 new int[][] { 
					{ 0, 0, 0 }, 
					{ 0, 7, 9 }, 
					{ 0, 13, 15 },
					{ 0, 19, 21 }
			 });
	}

	private void test(int[][] m, int[][] expected) {
		Solution s = new Solution();
		s.setZeroes(m);
		assertArrayEquals(expected, m);
	}
}
